package com.sqsf.controller;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.sqsf.javabean.Role;
import com.sqsf.javabean.SysLog;
import com.sqsf.service.SysLogService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;

import javax.servlet.http.HttpServletRequest;
import java.util.List;

@Controller
@RequestMapping("/syslog")
public class SyslogController {
    @Autowired
    SysLogService sysLogService;

    @RequestMapping("/findAll")
    public String findAll(HttpServletRequest request, @RequestParam(value = "page",required = false,defaultValue = "1") int page, @RequestParam(value = "limit",required = false,defaultValue = "5")int limit,@RequestParam(value = "username",required = false,defaultValue = "")String username,@RequestParam(value = "url",required = false,defaultValue = "")String url){
        PageHelper.startPage(page, limit);
        List<SysLog> all = sysLogService.findAll(username,url);
        PageInfo<SysLog> pageInfo=new PageInfo<>(all);
        request.setAttribute("pageInfo",pageInfo);
        request.setAttribute("username",username);
        request.setAttribute("url",url);
        return "/syslog/syslog-list";
    }
}